class Solution:
    #滑动窗口
    def lengthOfLongestSubstring(self, s: str) -> int:
        lengh = 0
        b = []
        for i in range(len(s)):
            if s[i] in b:
                lengh = max(lengh, len(b))
                b = b[b.index(s[i])+1:]
            b.append(s[i])
        lengh = max(len(b), lengh)
        return lengh

if __name__ == '__main__':
    s = Solution()
    a = "abcabcbb"
    print(s.lengthOfLongestSubstring(a))